package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class PARFactory extends AbstractTokenVisitorFactory {

	private static PARFactory INSTANCE;
	
	private EXPR33Factory expr33Factory ;
	private VALORFactory valorFactory;
	
	public static PARFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new PARFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			expr33Factory = EXPR33Factory.getInstance();
			valorFactory = VALORFactory.getInstance();
		}
	};
	
	
	private PARFactory() throws Exception {
	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		initializer.init();

		return expr33Factory.makeChainedVisitor(valorFactory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();

		return expr33Factory.makeChainedVisitor(valorFactory.makeVisitor());
	}
	
	
}
